package controller

import (
	"api/core/errmsg"
	"api/midlib"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Upload(c *gin.Context) {
	file, fileHeader, _ := c.Request.FormFile("file")

	fileSize := fileHeader.Size

	url, code := midlib.UploadFile(file, fileSize)

	c.JSON(http.StatusOK, gin.H{
		"code":  code,
		"msg": errmsg.GetErrMsg(code),
		"data": gin.H{
			"url": url,
		},
	})

}

